package com.yjq.blog.advice;

import com.yjq.blog.vo.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@Slf4j
// @RestControllerAdvice
public class GlobalExceptionAdvice {

    // @ExceptionHandler(value = Exception.class)
    public Response<Object> handlerAdException(HttpServletRequest req, Exception ex) {
        log.error("------------------------------");
        log.error(ex.getMessage());
        log.error("------------------------------");
        return Response.fail(-1, ex.getMessage());
    }

}
